<template>
  <div class="branchIncome" v-loading="loading">
    <div class="logoBg"><img src="~@/assets/images/common/fiveG.png" /></div>
    <div class="heading">
      收入分析：<span class="redTitle">{{ nextLvlName }}收入完成情况 </span>
    </div>
    <div class="page-content">
      <div class="contentLeft">
        <div class="growthRate">
          <div class="marg">
            <span class="weightFont">
              <span class="lingxing"></span>主营收入预算完成率：</span>
              <span class="normalFont">
                {{ currentLvlName }}{{ mainAnalysis.currentCompleteBudget }}%
              </span>
          </div>
          <div class="marg">
            <span class="normalFont sign">年度预算完成率前三：</span>
            <span class="normalBuleFont">{{mainAnalysis.topThreeAreaNames}}</span>
          </div>
          <div class="marg">
            <span class="normalFont sign">年度预算完成率后三：</span>
            <span class="normalRedFont">{{mainAnalysis.downThreeAreaNames}}</span>
          </div>
        </div>
        <!-- <div class="growthRate">
          <div class="marg">
            <span class="weightFont">
              <span class="lingxing"></span>基本面收入完成率：</span>
              <span class="normalFont">{{ currentLvlName }}{{ basicAnalysis.currentCompleteBudget }}%
            </span>
          </div>
          <div class="marg">
            <span class="normalFont sign">年度预算完成率前三：</span>
            <span class="normalBuleFont">{{ basicAnalysis.topThreeAreaNames }}</span>
          </div>
          <div class="marg">
            <span class="normalFont sign">年度预算完成率后三：</span>
            <span class="normalRedFont">{{ basicAnalysis.downThreeAreaNames }}</span>
          </div>
        </div> -->
        <div class="growthRate">
          <div class="marg">
            <span class="weightFont">
              <span class="lingxing"></span>产业数字化（省内）收入完成率：</span>
              <span class="normalFont">{{ currentLvlName }}{{ idctAnalysis.currentCompleteBudget }}%</span>
          </div>
          <div class="marg">
            <span class="normalFont sign">年度预算完成率前三：</span>
            <span class="normalBuleFont">{{ idctAnalysis.topThreeAreaNames}}</span>
          </div>
          <div class="marg">
            <span class="normalFont sign">年度预算完成率后三：</span>
            <span class="normalRedFont">{{ idctAnalysis.downThreeAreaNames }}</span>
          </div>
        </div>
        <div class="growthRate">
          <div class="marg">
            <span class="weightFont">
              <span class="lingxing"></span>码号级收入完成率：
            </span>
            <span class="normalFont">{{ currentLvlName }}{{ numberAnalysis.currentCompleteBudget }}%</span>
          </div>
          <div class="marg">
            <span class="normalFont sign">年度预算完成率前三：</span>
            <span class="normalBuleFont">{{ numberAnalysis.topThreeAreaNames }}</span>
          </div>
          <div class="marg">
            <span class="normalFont sign">年度预算完成率后三：</span>
            <span class="normalRedFont">{{ numberAnalysis.downThreeAreaNames }}</span>
          </div>
        </div>
      </div>
      <div class="contentRight">
        <div class="topEchart">
          <div class="contentTitle">
            {{ mainAnalysis.acctMonth }}月份{{ nextLvlName}}
            <span class="redTitle">主营收入和基本面收入</span>预算完成率
          </div>
          <BarChart :chartData="chartData1"></BarChart>
        </div>
        <div class="centerEchart">
          <div class="contentTitle">
            {{ idctAnalysis.acctMonth }}月份{{ nextLvlName
            }}<span class="redTitle">产业数字化（省内）收入</span>预算完成率
          </div>
          <BarChart :chartData="chartData2" :title="['产数拉动(pp)', '时序进度(%)']"></BarChart>
        </div>
        <div class="bottomEchart">
          <div class="contentTitle">
            {{ numberAnalysis.acctMonth }}月份{{ nextLvlName
            }}<span class="redTitle">码号级收入</span>预算完成率
          </div>
          <BarChart :chartData="chartData3"></BarChart>
        </div>
      </div>
    </div>
    <div class="contentBottom">
      <span class="normal">注：</span>
      <span class="blod">基本面收入：</span>
      <span class="normal">主营收入-产业数字化（省内）收入；</span>
      <span class="blod">产业数字化（省内）收入：</span>
      <span class="normal">IDC收入+行业云收入+数字平台和大数据（省内）+组网专线+物联网+互联网金融；</span>
      <span class="blod">码号级收入：</span>
      <span class="normal">四大主量资产计费平台主量科目收入，含大单。</span>
    </div>
  </div>
</template>

<script>
import { $budgetAPI } from "@/api";
export default {
  name: "branchIncome",
  props: {
    form: {
      type: Object,
      default: {}
    }
  },
  components: {
    BarChart: () => import("./charts/page3Chart.vue")
  },
  data() {
    return {
      loading: false,
      number: 10,
      currentLvlName: "",
      mainAnalysis: {},
      basicAnalysis: {},
      numberAnalysis: {},
      idctAnalysis: {},
      firstEchart: {},
      nextLvlName: "",

      chartData1: [],
      chartData2: [],
      chartData3: [],

      gapOfBudgetLjList: [],
      widthChange: "",
    };
  },
  created(){
    
  },
  methods: {
    getData() {
      this.loading = true;
      $budgetAPI.getCountyOperationPageThree(
        { token: this.form.token, areaId: this.form.areaId, acctMonth: this.form.month },
        (res) => {
          if (res && res.code == 0) {
            this.currentLvlName = res.content.currentLvlName;
            this.$emit("update:currentLvlName", res.content.currentLvlName);
            this.nextLvlName = res.content.nextLvlName;
            this.mainAnalysis = res.content.mainAnalysis;
            this.basicAnalysis = res.content.basicAnalysis || {};
            this.numberAnalysis = res.content.numberAnalysis;
            this.idctAnalysis = res.content.idctAnalysis;
            this.gapOfBudgetLjList = res.content.mainAnalysis.gapOfBudgetLjList;

            const { mainAnalysis, idctAnalysis, numberAnalysis } = res.content;
            this.chartData1 = mainAnalysis.data;
            this.chartData2 = idctAnalysis.data;
            this.chartData3 = numberAnalysis.data;
            this.width();
            this.loading = false;
          }
        },
        (err) => {
          this.loading = false;
        }
      );
    },
    width() {
      this.widthChange =
        (this.$refs.budgetLjList.clientWidth - 1) /
        this.gapOfBudgetLjList.length;
    },
  },
};
</script>

<style lang="scss" scoped>
.branchIncome {
  padding: 20px;
  border: 1px solid #dee5f3;
  border-radius: 5px;
  margin-top: 20px;
  position: relative;
  .logoBg {
    position: absolute;
    right: 20px;
    top: 20px;
  }
  .heading {
    font-size: 22px;
    font-weight: 700;
    text-align: center;
    padding-bottom: 30px;
    .redTitle {
      color: #c00000;
    }
  }
  .page-content {
    // display: flex;
    overflow: hidden;
    padding-top: 10px;
    .contentLeft {
      width: 370px;
      float: left;
      .growthRate {
        margin-bottom: 40px;
        .marg {
          margin-bottom: 10px;
          .weightFont {
            font-size: 18px;
            font-weight: 700;
            .lingxing {
              width: 10px;
              height: 10px;
              background-color: #c00000;
              transform: rotate(45deg);
              -ms-transform: rotate(45deg); /* Internet Explorer */
              -moz-transform: rotate(45deg); /* Firefox */
              -webkit-transform: rotate(45deg); /* Safari 和 Chrome */
              -o-transform: rotate(45deg); /* Opera */
              margin-right: 7px;
              display: inline-block;
            }
          }
          .normalFont {
            font-size: 16px;
            &.sign {
              padding-left: 20px;
              display: inline;
              position: relative;
              &::before {
                content: "-";
                color: #333;
                position: absolute;
                left: 0;
              }
            }
          }
          .normalBuleFont {
            font-size: 16px;
            color: #5585bf;
          }
          .normalRedFont {
            font-size: 16px;
            color: #c00000;
          }
          .weightRedlFont {
            font-size: 16px;
            color: #c00000;
            font-weight: 700;
            &.sign {
              padding-left: 20px;
              display: inline;
              position: relative;
              &::before {
                content: "-";
                color: #333;
                font-weight: normal;
                position: absolute;
                left: 0;
              }
            }
          }
        }
      }
    }
    .contentRight {
      // flex: 1;
      width: calc(100% - 370px);
      float: right;
      .topEchart {
        width: 100%;
        position: relative;
        border: 1px solid #e5e5e5;
        border-radius: 10px;
        padding: 20px 0 10px 0;
        display: inline-block;
        height: 230px;

        &:before {
          content: "";
          position: absolute;
          left: 17%;
          top: -2px;
          width: 66%;
          height: 2px;
          background-color: #fff;
        }
      }
      .centerEchart {
        width: 100%;
        position: relative;
        border: 1px solid #e5e5e5;
        border-radius: 10px;
        padding: 20px 0 10px 0;
        display: inline-block;
        height: 230px;
        margin: 3% 0;
        &:before {
          content: "";
          position: absolute;
          left: 20%;
          top: -2px;
          width: 60%;
          height: 2px;
          background-color: #fff;
        }
      }
      .bottomEchart {
        width: 100%;
        position: relative;
        border: 1px solid #e5e5e5;
        border-radius: 10px;
        padding: 20px 0 10px 0;
        display: inline-block;
        height: 230px;
        margin-bottom: 1%;
        &:before {
          content: "";
          position: absolute;
          left: 20%;
          top: -2px;
          width: 60%;
          height: 2px;
          background-color: #fff;
        }
      }
      .contentTitle {
        position: absolute;
        left: 50%;
        top: -14px;
        transform: translateX(-50%);
        font-size: 18px;
        font-weight: 700;
        text-align: center;
        width: 65%;
        .redTitle {
          color: #e46c11;
        }
      }
      .lackData {
        padding: 0 0px 0 55px;
        .title {
          width: 51px;
          display: inline-block;
          vertical-align: top;
          margin-left: -55px;
        }
        .gapOfTitle {
          display: inline-block;
          width: 100%;
          li {
            float: left;
            border: 1px solid #5585bf;
            color: #5585bf;
            text-align: center;
            height: 18px;
            line-height: 18px;
          }
          // li:nth-child(1){
          //   width:60px !important;
          // }
        }
      }
    }
  }
  .contentBottom {
    padding-top: 45px;
    .normal {
      font-size: 14px;
    }
    .blod {
      font-size: 14px;
      font-weight: 700;
    }
  }
}
</style>
